package com.zh.operation.service.impl;

import com.zh.common.domain.DictDO;
import com.zh.operation.dao.OperationGoodsDao;
import com.zh.operation.domain.OperationGoodsDO;
import com.zh.operation.domain.OperationGoodsDOVO;
import com.zh.operation.service.OperationGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;


@Service
public class OperationGoodsServiceImpl implements OperationGoodsService {
	@Autowired
	private OperationGoodsDao operationGoodsDao;
	
	@Override
	public OperationGoodsDO get(String id){
		return operationGoodsDao.get(id);
	}
	
	@Override
	public List<OperationGoodsDOVO> list(Map<String, Object> map){
		return operationGoodsDao.list(map);
	}

	@Override
	public List<DictDO> listGoodsType() {
		return operationGoodsDao.listGoodsType();
	}

	@Override
	public int count(Map<String, Object> map){
		return operationGoodsDao.count(map);
	}
	
	@Override
	public int save(OperationGoodsDO goods){
		goods.setId(new SimpleDateFormat("yyyyMMddHHmmssSS").format(new Date()) + (int) ((Math.random() * 9 + 1) * 1000));
		goods.setCreateDate(new Date());
		goods.setDelFlag("0");
		return operationGoodsDao.save(goods);
	}
	
	@Override
	public int update(OperationGoodsDO goods){
		return operationGoodsDao.update(goods);
	}
	
	@Override
	public int remove(String id){
		return operationGoodsDao.remove(id);
	}
	
	@Override
	public int batchRemove(String[] ids){
		return operationGoodsDao.batchRemove(ids);
	}

	@Override
	public OperationGoodsDO isExist(String goodsName) {
		return operationGoodsDao.isExist(goodsName);
	}

}
